import pymysql

conn = pymysql.connect(
    host='127.0.0.1',
    port=3306,
    user='root',
    password='123456',
    database='mumushouji',
    charset='utf8',
    # cursorclass=pymysql.cursors.DictCursor
)

username = '2@qq.com'
user_id = '2'
sql = 'select * from user where username=%(username)s and user_id = %(user_id)s'
cursor = conn.cursor(cursor=pymysql.cursors.DictCursor)
params = {
    'username': username,
    'user_id': user_id
}
cursor.execute(sql, params)

result = cursor.fetchall()
print(result)

cursor.close()
conn.close()
